//by: Daniel Diaz, Nicolas Ladron de Guevara, Jesse Caicedo

#include<pic18f458.h>

#pragma interrupt IntHandler ipl1 vector 0

void IntHandler(void)
{
    asm("ei");
    //High priority RX0
    if(PIR3==1){
        }
        PIR3=0; //Flag Down
    
    //Low priority TX0
    else if(PIR3==4){
        }
        PIR3=0; //Flag Down
    
    //wait
    while(1);{
        PORTA=0;
    PIR3=0;//All INT flags Down
             }
}

int main(){

    INTCON=128;//Enable global interrupts
    PIE3=5;//Enable RX and TX Buff0 INT
    IPR3=1;//TX-->Low Priority  RX-->High Priority

CANCON=0x08;
//configuracion TX para Buff0
TXB1SIDH=0xFF;  // identificador '11111111111'
TXB1SIDL=0xE0;
TXB1D1=1;
TXB1DLC=1;
TXB1EIDH=0;
TXB1EIDL=2; // send 2 

//configuracion RX para Buff0
RXM1SIDH=0x00;  // acepta cualquier dato-- Mascara=0
RXM1SIDL=0x00;
RXB1DLC=1;

//BRG config
BRGCON1=0x00;
BRGCON2=0x93;
BRGCON3=0x02;

while(1);

}



